package com.pethospital.entity;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

/**
 * 预约实体类
 * Appointment Entity Class
 * 
 * @author PetHospital System
 * @version 1.0
 */
public class Appointment {
    
    private Integer appointmentId;      // 预约ID
    private Integer petId;              // 宠物ID
    private Integer ownerId;            // 主人ID
    private Date appointmentDate;       // 预约日期
    private Time appointmentTime;       // 预约时间
    private String serviceType;         // 服务类型（体检、治疗、疫苗等）
    private String symptoms;            // 症状描述
    private String status;              // 预约状态：pending-待确认，confirmed-已确认，completed-已完成，cancelled-已取消
    private String doctorName;          // 医生姓名
    private String notes;               // 备注
    private Timestamp createTime;       // 创建时间
    private Timestamp updateTime;       // 更新时间
    
    // 关联对象
    private Pet pet;                    // 宠物信息
    private User owner;                 // 主人信息

    /**
     * 默认构造函数
     */
    public Appointment() {
    }

    /**
     * 带参构造函数
     */
    public Appointment(Integer petId, Integer ownerId, Date appointmentDate, Time appointmentTime,
                      String serviceType, String symptoms) {
        this.petId = petId;
        this.ownerId = ownerId;
        this.appointmentDate = appointmentDate;
        this.appointmentTime = appointmentTime;
        this.serviceType = serviceType;
        this.symptoms = symptoms;
        this.status = "pending";
    }

    // Getter和Setter方法
    public Integer getAppointmentId() {
        return appointmentId;
    }

    public void setAppointmentId(Integer appointmentId) {
        this.appointmentId = appointmentId;
    }

    public Integer getPetId() {
        return petId;
    }

    public void setPetId(Integer petId) {
        this.petId = petId;
    }

    public Integer getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(Integer ownerId) {
        this.ownerId = ownerId;
    }

    public Date getAppointmentDate() {
        return appointmentDate;
    }

    public void setAppointmentDate(Date appointmentDate) {
        this.appointmentDate = appointmentDate;
    }

    public Time getAppointmentTime() {
        return appointmentTime;
    }

    public void setAppointmentTime(Time appointmentTime) {
        this.appointmentTime = appointmentTime;
    }

    public String getServiceType() {
        return serviceType;
    }

    public void setServiceType(String serviceType) {
        this.serviceType = serviceType;
    }

    public String getSymptoms() {
        return symptoms;
    }

    public void setSymptoms(String symptoms) {
        this.symptoms = symptoms;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDoctorName() {
        return doctorName;
    }

    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    public Pet getPet() {
        return pet;
    }

    public void setPet(Pet pet) {
        this.pet = pet;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    /**
     * 获取状态显示文本
     */
    public String getStatusDisplay() {
        switch (status) {
            case "pending": return "待确认";
            case "confirmed": return "已确认";
            case "completed": return "已完成";
            case "cancelled": return "已取消";
            default: return "未知";
        }
    }

    /**
     * 获取状态颜色类
     */
    public String getStatusColor() {
        switch (status) {
            case "pending": return "warning";
            case "confirmed": return "info";
            case "completed": return "success";
            case "cancelled": return "danger";
            default: return "secondary";
        }
    }

    /**
     * 判断是否可以取消
     */
    public boolean canCancel() {
        return "pending".equals(status) || "confirmed".equals(status);
    }

    /**
     * 判断是否可以确认
     */
    public boolean canConfirm() {
        return "pending".equals(status);
    }

    @Override
    public String toString() {
        return "Appointment{" +
                "appointmentId=" + appointmentId +
                ", petId=" + petId +
                ", ownerId=" + ownerId +
                ", appointmentDate=" + appointmentDate +
                ", appointmentTime=" + appointmentTime +
                ", serviceType='" + serviceType + '\'' +
                ", status='" + status + '\'' +
                ", doctorName='" + doctorName + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}
